A5Storage::DataContainer WriteItemToStream Method
Syntax
.WriteItemToStream as L (Data as System::IO::Stream, BYREF LengthReturned as N, BYREF ContentType as C, TargetPath as C)
Arguments
- DataSystem::IO::Stream
The stream to which data is written.
- BYREF LengthReturnedNumeric
The amount of data returned in the stream.
- BYREF ContentTypeCharacter
The content type. E.g. "text/html"
- TargetPathCharacter
The item in the Storage container to write to stream.
Returns
- ResultLogical
Returns .T. if the operation succeeds, otherwise .F. (see .CallResult for additional error information.)
Description
Retrieves an item from the Storage container using the name provided and writes it to the provided stream variable.
Discussion
You must DIM variables for Stream, LengthReturned, and ContentType prior to making the call.
Example
dim Stream as System::IO::Stream = null_value()
dim ContentType as C
dim Length as N
dim Buffer as B
dim CallResult as CallResult
dim Container as A5Storage::DataContainer = null_value()
Stream = new System::IO::MemoryStream()
CallResult = A5Storage::DataContainer::Open(Container, "Provider='Disk';Container='c:\A5Webroot';")
if CallResult.Success
if Container.WriteItemToStream(Stream, Length, ContentType, "Speak.a5w")
Stream.Seek(0, System::IO::SeekOrigin::Begin)
dim Reader as System::IO::BinaryReader = new System::IO::BinaryReader(Stream)
Buffer = Reader.ReadBytes(Length)
Stream.close()
else
CallResult = Container.CallResult
end if
end if
if CallResult.Success
showvar("Type: " + ContentType + crlf() + "Length: " + Length + crlf(2) + buffer, "Success")
else
showvar(CallResult.Text, "Error")
end if